/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is Forte for Java, Community Edition. The Initial * Developer of the Original Code is Sun Microsystems, Inc. Portions * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.projects; import org.openide.*; import java.awt.*; import java.awt.event.*; import java.net.*; import javax.swing.*; import java.io.File; import java.util.*; import org.openide.*; import org.openide.filesystems.*; /** * Main import panel * @author Petr Zajac */ public class ImportPanel2 extends javax.swing.JPanel { ImportProject im ; /** * @associates LocFileSystemDescriptor */ public Vector IdeFileSystems = new Vector (); /** Creates new form ImportPanel2 */ public ImportPanel2 ( ImportProject im) { this.im = im; initComponents (); refreshData (); fileSystemsComboBox.setEnabled (false); } /** load data to filesList, fileSystemList, fileSystemCompboBox */ protected void refreshData () { File files[] = im.getFileSystems (); int i=0; Object strng[] = new String[files.length]; for (;i < files.length ; i++ ) { strng[i]=files[i].getAbsolutePath(); } repositoryList.setListData (strng); files = im.getFiles (); // System.out.println(files.length); strng = new String [files.length]; for (i = 0;i < files.length ; i++ ) { strng[i]=files[i].getAbsolutePath (); // System.out.println(files[i].getPath()); } filesList.setListData (strng); Repository repository = TopManager.getDefault ().getRepository (); Enumeration en = repository.getFileSystems (); FileSystem fs = null; // add fileSystems into comboBox // LocalFileSystem locFs = null; if (en.hasMoreElements () ) { // first is system - ignored en.nextElement (); } while (en.hasMoreElements ()) { fs = (FileSystem) en.nextElement (); if (fs instanceof LocalFileSystem) { locFs = (LocalFileSystem) fs; if (locFs.isHidden () == false ) { IdeFileSystems.addElement ( new LocFileSystemDescriptor ( locFs)); fileSystemsComboBox.addItem ( new LocFileSystemDescriptor ( locFs)); } } } ///// // init componets 2 ButtonGroup group = new ButtonGroup (); group.add (insertIntoCurrentProjectRadio); group.add (createNewProjectRadio); insertIntoCurrentProjectRadio.setText (Import.getLocalizedString ("CTL_ImportInsertIntoCurrentProjectRadio")); // NOI18N createNewProjectRadio.setText (Import.getLocalizedString ("CTL_ImportCreateNewProjectRadio")); // NOI18N copyCheckBox.setText (Import.getLocalizedString ("CTL_ImportCopyFileSystemsCheckBox")); // NOI18N org.openide.nodes.Node n = TopManager.getDefault ().getPlaces ().nodes ().projectDesktop (); ProjectDataObject project = (ProjectDataObject)n.getCookie (ProjectDataObject.class); if (project == null) { createNewProjectRadio.setSelected (true); insertIntoCurrentProjectRadio.setEnabled (false); } } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the FormEditor. */ private void initComponents () {//GEN-BEGIN:initComponents copyCheckBox = new javax.swing.JCheckBox (); jPanel1 = new javax.swing.JPanel (); createNewProjectRadio = new javax.swing.JRadioButton (); insertIntoCurrentProjectRadio = new javax.swing.JRadioButton (); fileSystemsComboBox = new javax.swing.JComboBox (); jPanel2 = new javax.swing.JPanel (); jScrollPane1 = new javax.swing.JScrollPane (); repositoryList = new javax.swing.JList (); jPanel3 = new javax.swing.JPanel (); jScrollPane4 = new javax.swing.JScrollPane (); filesList = new javax.swing.JList (); setLayout (new java.awt.GridBagLayout ()); java.awt.GridBagConstraints gridBagConstraints1; copyCheckBox.setText ("Copy File Systems "); // NOI18N copyCheckBox.addChangeListener (new javax.swing.event.ChangeListener () { public void stateChanged (javax.swing.event.ChangeEvent evt) { copyCheckBoxStateChanged (evt); } } ); gridBagConstraints1 = new java.awt.GridBagConstraints (); gridBagConstraints1.gridx = 2; gridBagConstraints1.gridy = 3; gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints1.insets = new java.awt.Insets (4, 8, 4, 4); add (copyCheckBox, gridBagConstraints1); jPanel1.setLayout (new java.awt.GridLayout (2, 1)); createNewProjectRadio.setText ("create new project"); // NOI18N jPanel1.add (createNewProjectRadio); insertIntoCurrentProjectRadio.setSelected (true); insertIntoCurrentProjectRadio.setText ("Insert Into current project"); // NOI18N jPanel1.add (insertIntoCurrentProjectRadio); gridBagConstraints1 = new java.awt.GridBagConstraints (); gridBagConstraints1.gridx = 2; gridBagConstraints1.gridy = 2; gridBagConstraints1.gridwidth = 3; gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints1.insets = new java.awt.Insets (4, 8, 4, 8); add (jPanel1, gridBagConstraints1); gridBagConstraints1 = new java.awt.GridBagConstraints (); gridBagConstraints1.gridx = 3; gridBagConstraints1.gridy = 3; gridBagConstraints1.gridwidth = 2; gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints1.insets = new java.awt.Insets (4, 4, 4, 8); gridBagConstraints1.weightx = 0.1; add (fileSystemsComboBox, gridBagConstraints1); jPanel2.setLayout (new java.awt.GridLayout (1, 1)); jScrollPane1.setViewportView (repositoryList); jPanel2.add (jScrollPane1); gridBagConstraints1 = new java.awt.GridBagConstraints (); gridBagConstraints1.gridx = 2; gridBagConstraints1.gridy = 0; gridBagConstraints1.gridwidth = 3; gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints1.insets = new java.awt.Insets (8, 8, 4, 8); gridBagConstraints1.weightx = 1.0; gridBagConstraints1.weighty = 0.2; add (jPanel2, gridBagConstraints1); jPanel3.setLayout (new java.awt.GridLayout (1, 1)); jScrollPane4.setViewportView (filesList); jPanel3.add (jScrollPane4); gridBagConstraints1 = new java.awt.GridBagConstraints (); gridBagConstraints1.gridx = 2; gridBagConstraints1.gridy = 1; gridBagConstraints1.gridwidth = 0; gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints1.insets = new java.awt.Insets (4, 8, 4, 8); gridBagConstraints1.weightx = 1.0; gridBagConstraints1.weighty = 0.2; add (jPanel3, gridBagConstraints1); }//GEN-END:initComponents private void copyCheckBoxStateChanged (javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_copyCheckBoxStateChanged // Add your handling code here: /// Add your handling code here: if (copyCheckBox.isSelected()) { fileSystemsComboBox.setEnabled (true); } else { fileSystemsComboBox.setEnabled (false); } }//GEN-LAST:event_copyCheckBoxStateChanged // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JCheckBox copyCheckBox; private javax.swing.JPanel jPanel1; private javax.swing.JRadioButton createNewProjectRadio; private javax.swing.JRadioButton insertIntoCurrentProjectRadio; private javax.swing.JComboBox fileSystemsComboBox; private javax.swing.JPanel jPanel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JList repositoryList; private javax.swing.JPanel jPanel3; private javax.swing.JScrollPane jScrollPane4; private javax.swing.JList filesList; // End of variables declaration//GEN-END:variables /** * return true if filesystems of imported project will be copied */ public boolean isCopy() { return copyCheckBox.isSelected(); } /** * return destination FileSystem */ public LocalFileSystem getSelectedFileSystem() { Object obj = fileSystemsComboBox.getSelectedItem(); if (obj != null) { return ((LocFileSystemDescriptor) obj).fileSystem; } else { return null; } } public boolean isCreateNewProject() { return createNewProjectRadio.isSelected(); } /** Encapsulation LocalFileSystem for showing in ComboBox */ protected class LocFileSystemDescriptor { public LocalFileSystem fileSystem; public LocFileSystemDescriptor (LocalFileSystem fileSystem) { this.fileSystem = fileSystem; } public String toString () { return fileSystem.getDisplayName (); } } } /* * Log * 3 Gandalf 1.2 1/15/00 Ian Formanek NOI18N * 2 Gandalf 1.1 1/13/00 Martin Ryzl heavy localization * 1 Gandalf 1.0 1/3/00 Martin Ryzl * $ */